
package cn.zlg.common.springmvc.validate;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import cn.zlg.common.springmvc.apiresultproperty.ApiThirtyFourResult;
import org.springframework.validation.BindingResult;

public class DefaultJsonExceptionResponseBodyBuilder implements JsonExceptionResponseBodyBuilder {

    @Override
    public Map<String, Object> build(Exception exception, BindingResult bingBindingResult, int code,
                                     String errorString) {
        Map<String, Object> map = new TreeMap<String, Object>();
        map.put("code", code);
        map.put("msg", errorString);
        return map;
    }


    @Override
    public Map<String, Object> apiThirtyFourTokenReturn(ApiThirtyFourResult apiThirtyFourResult) {
        Map<String, Object> hashMap = new HashMap<>();
        hashMap.put("errorCode", apiThirtyFourResult.getErrorCode());
        hashMap.put("errorMsg", apiThirtyFourResult.getErrorMsg());
        hashMap.put("filedErr", apiThirtyFourResult.getFiledErr());
        hashMap.put("data", apiThirtyFourResult.getData());
        hashMap.put("valid", false);
        return hashMap;
    }

}
